<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title>图片预加载</title>
    <script type="text/javascript" src="<?php echo PUBLIC_PATH;?>/js/jquery.js"></script>

</head>
<body>
<div class="box">
    <div> 1111</div>
</div>
<script type="text/javascript">
//    function loadImage(url,callback) {
//        var img =new Image();
//        img.onload =function(){
//            img.onload =null;
//            callback(img);
//        }
//        img.src = url;
//    }
    function loadImage(url, callback) {
        var img = new Image();
        img.onload =  function(){
            img.onload = null;
            callback(img);
        }
        img.src = url;
    }


    function call(img){
        $(img).appendTo('.box');
    }
    // loadImage('http://www.appelsiini.net/projects/lazyload/img/viper_1.jpg',call);  
    loadImage('<?php echo PUBLIC_PATH;?>/image/1.png',call);

</script>
</body>
</html>